﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using nanoCMS.Core.Concrete;
using nanoCMS.Core.Providers;

namespace nanoCMS.Core.WebProviders {
	public class NavigationProvider {
		private readonly WorldContext _worldContext;
		private const string NavigationCacheKey = "NavigationData";
		private CacheProvider cacheProvider = CacheProvider.Default;
		public NavigationProvider(WorldContext worldContext) {
			_worldContext = worldContext;
		}


		public List<TenantNavigationItem> GetNavigationItems(int navigationId) {
			if (!cacheProvider.Contains(NavigationCacheKey + navigationId)) {

				cacheProvider.Add(NavigationCacheKey + navigationId,
					_worldContext.Entities.TenantNavigationItems.Where(x => x.NavigationID == navigationId).OrderBy(x => x.Order).ToList());
			}

			return cacheProvider.Get(NavigationCacheKey + navigationId) as List<TenantNavigationItem>;

		}


	}
}
